import { ApiProperty } from '@nestjs/swagger';
import { Column, Entity } from 'typeorm';
import { BaseEntity } from '../../common/entity/base.entity';

export enum JobStatus {
  OPEN = 'OPEN',
  DISTRIBUTED = 'DISTRIBUTED',
  IN_PROGRESS = 'IN_PROGRESS',
  COMPLETED = 'COMPLETED',
  CANCELLED = 'CANCELLED',
  EXPIRED = 'EXPIRED'
}

@Entity('jobs')
export class Job extends BaseEntity {
  @ApiProperty({ description: '任务标题' })
  @Column({ name: 'jobTitle', type: 'text' })
  jobTitle: string;

  @ApiProperty({ description: '任务分类' })
  @Column({ name: 'category', type: 'text' })
  category: string;

  @ApiProperty({ description: '任务描述' })
  @Column({ name: 'description', type: 'text' })
  description: string;

  @ApiProperty({ description: '交付物' })
  @Column({ name: 'deliverables', type: 'text' })
  deliverables: string;

  @ApiProperty({ description: '预算信息', type: 'object', additionalProperties: true })
  @Column({ name: 'budget', type: 'jsonb' })
  budget: Record<string, any>;

  @ApiProperty({ description: '最大预算', required: false })
  @Column({ name: 'maxBudget', type: 'double precision', nullable: true })
  maxBudget?: number;

  @ApiProperty({ description: '截止时间' })
  @Column({ name: 'deadline', type: 'timestamp' })
  deadline: Date;

  @ApiProperty({ description: '支付类型' })
  @Column({ name: 'paymentType', type: 'text' })
  paymentType: string;

  @ApiProperty({ description: '优先级' })
  @Column({ name: 'priority', type: 'text' })
  priority: string;

  @ApiProperty({ description: '技能等级' })
  @Column({ name: 'skillLevel', type: 'text' })
  skillLevel: string;

  @ApiProperty({ description: '标签', type: [String] })
  @Column({ name: 'tags', type: 'text', array: true, default: [] })
  tags: string[];

  @ApiProperty({ description: '任务状态', enum: JobStatus })
  @Column({ name: 'status', type: 'enum', enum: JobStatus, default: JobStatus.OPEN })
  status: JobStatus;

  @ApiProperty({ description: '是否自动分配' })
  @Column({ name: 'autoAssign', type: 'boolean', default: false })
  autoAssign: boolean;

  @ApiProperty({ description: '是否允许竞价' })
  @Column({ name: 'allowBidding', type: 'boolean', default: true })
  allowBidding: boolean;

  @ApiProperty({ description: '是否允许并行执行' })
  @Column({ name: 'allowParallelExecution', type: 'boolean', default: false })
  allowParallelExecution: boolean;

  @ApiProperty({ description: '是否启用托管' })
  @Column({ name: 'escrowEnabled', type: 'boolean', default: true })
  escrowEnabled: boolean;

  @ApiProperty({ description: '是否公开' })
  @Column({ name: 'isPublic', type: 'boolean', default: true })
  isPublic: boolean;

  @ApiProperty({ description: '钱包地址' })
  @Column({ name: 'walletAddress', type: 'text' })
  walletAddress: string;
} 